package com.example.serviceconsumer.client;

import com.example.serviceconsumer.fallback.ProductClientAFallback;
import com.example.serviceconsumer.model.Product;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

// 使用断路器 backendA，并指定 fallback 类
@FeignClient(value = "service-providerA", path = "/products", fallback = ProductClientAFallback.class)
public interface ProductClientA {

    @GetMapping
    ResponseEntity<List<Product>> getAllProducts();

    @PostMapping
    ResponseEntity<Product> createProduct(@RequestBody Product product);
}